import re

from django import http
from django.shortcuts import render

# Create your views here.
from django.views import View


class LoginView(View):
    def get(self, request):
        return render(request, 'login.html')

    def post(self, request):
        # 获取参数
        phone = request.POST.get('phone')
        password = request.POST.get('password')
        print(password)
        # 校验参数
        if not all([phone, password]):
            return http.HttpResponseBadRequest('参数不全哦！')
        if not re.match(r'^1[3-9]\d{9}$', phone):
            return http.HttpResponseBadRequest('手机号不对')
        # if allow != 'on':
        #     return http.HttpResponseBadRequest('请同意协议')

class RegisterView(View):
    def get(self,request):
        return render(request, 'register.html')